<?php
class RegionController extends Controller
{
    public function actionAjax_init() {

    	$cStateId=1;
        $cProvinceId=2;
        $cCityId=52;
        $cRegionId=500;
        //省份
        $sql='SELECT "region_id","region_name" FROM {{region}} WHERE "parent_id"="'.$cStateId.'" ORDER BY "region_id" ASC';
        $result = Yii::app()->db->createCommand($sql);
        $rows=$result->queryAll();
        if($rows!==null){
            $res['content']['province'] = $result->queryAll();
        }else{
            $res['content']['province'] =null;
        }

       
        
        $res['success']=1;
        
        echo json_encode($res);
    }
    
    public function actionAjax_region(){
        $id=(int)Yii::app()->request->getParam("id");
        do{
            if(!$id>0){
                $res['success']=-1;
                break;
            }
            
            $sql='SELECT "region_id","region_name" FROM {{region}} WHERE "parent_id"='.$id;
            
            $result = Yii::app()->db->createCommand($sql);
            $res['datas'] = $result->queryAll();
            
            
            $res['success']=1;
            
        }while (false);
        
        echo json_encode($res);
        
    }
    
   
    
    
}